/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
 
package 费马素性检验;


public class 费马素性检验 {
int runFermatPower(int a, int b, int n)// d≡a^b mod n  
{  
    int result = 1;  
    while (b > 0) {  
        if ((b & 1) == 1)  
            result = (result * a) % n;  
  
        b >>= 1;  
        a = (a * a) % n;  
    }  
    return result;  
} 

    public static void main(String[] args) {
        // TODO code application logic here
        public void (int n){  
    for(int i = 2; i <= n; i++){  
        if(runFermatPower(2, n-1, n) != 1){  
            boolean i不在伪素数表中;
            if(i不在伪素数表中)  
                输出i;  
        }  
    }  
}  
}
